package com.crm.system.service.impl.trainingManager;

import com.crm.common.model.DhPageInfo;
import com.crm.model.vo.trainingManager.TrainingContractVO;
import com.crm.model.vo.trainingManager.TrainingOrderProductDetailVO;
import com.crm.service.trainingManager.TrainingOrderProductDbService;
import com.crm.system.service.trainingManager.TrainingOrderProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author yincuimei
 * @Date 2021/9/17 9:03
 */
@Service
public class TrainingOrderProductServiceImpl implements TrainingOrderProductService {
    @Autowired
    private TrainingOrderProductDbService trainingOrderProductDbService;

    /**
     * (用户模块)内训管理-》内训合同列表-》合同详情-》产品信息
     * @param contractId          --合同ID
     * @param pageIndex/pageSize  --页码/分页大小
     * @param sortName/sortOrder  --排序字段/排序规则
     * @author yincuimei
     * @return
     */
    @Override
    public DhPageInfo<TrainingOrderProductDetailVO> selectTrainingOrderProductVOList(String contractId,Integer pageIndex,Integer pageSize,String sortName,String sortOrder) {
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }
        //排序(目前无排序)
        StringBuilder order = new StringBuilder();
        if (!StringUtils.isBlank(sortName) && !StringUtils.isBlank(sortOrder)) {
            switch (sortName) {

            }
        }
        List<TrainingOrderProductDetailVO> trainingOrderProductVOList = trainingOrderProductDbService.selectTrainingOrderProductVOList(contractId,order.toString());
        PageInfo<TrainingOrderProductDetailVO> pageInfo =  new PageInfo(trainingOrderProductVOList);
        return new DhPageInfo<TrainingOrderProductDetailVO>(pageInfo, trainingOrderProductVOList);
    }
}
